package definition;

import domain.SuperUser;
import domain.User;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;

/**
 * 合并 Bean 定义
 * {@link DefaultListableBeanFactory#getMergedBeanDefinition(String, BeanDefinition)}
 * @author jackcfan
 * @date 2021/9/25
 */
public class MergedBeanDefinitionTest {

    public static void main(String[] args) {
        DefaultListableBeanFactory beanFactory = new DefaultListableBeanFactory();
        XmlBeanDefinitionReader beanDefinitionReader = new XmlBeanDefinitionReader(beanFactory);
        beanDefinitionReader.loadBeanDefinitions("bean-context.xml");

        User user = beanFactory.getBean("user", User.class);
        // superUser 继承 User
        SuperUser superuser = beanFactory.getBean("superUser", SuperUser.class);

        System.out.println("user>"+user);
        System.out.println("superUser>"+superuser);
    }
}
